package com.langsin.LinkedListDemo;
/**
@Auther: MFM
@Date: 2021/7/21 - 07 - 21 - 20:28 
@version: 1.0
*/

public class LinkedListStack<E> implements Stack<E>{

    //底层链表
    private LinkedList<E> list;

    @Override
    public void push(E e) {
        list.addFirst(e);
    }

    @Override
    public E pop() {
        return list.removeFirst();
    }

    @Override
    public E peek() {
        return list.getFirst();
    }

    @Override
    public int getSize() {
        return list.getSize();
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }

    @Override
    public String toString() {
        StringBuilder res =new StringBuilder();
        res.append("Stack：栈顶");
        res.append(list);
        return res.toString();
    }
}
